import numpy as np
import matplotlib.pyplot as plt

numbers = [
    103,
    343,
    423,
    123,
    212,
    300,
    111,
    252,
    107,
    120,
    188,
    156,
    236,
    200,
    150,
    160,
]
tail = [x % 10 for x in numbers]
print(tail)
bins = np.arange(0, 10, 1)
print(bins)
plt.hist(tail, bins, rwidth=0.8, align="left")  # 条形宽度设为区段宽度的80%
# 为了显示中文，指定默认字体
# plt.rcParams['font.sans-serif'] = ['SimHei']
# 设置刻度字体大小
plt.xticks(bins, fontsize=15)
plt.yticks(fontsize=15)
plt.xlim(min(bins) - 1, len(bins))
plt.ylim(min(tail), max(tail) + 1)
plt.xlabel("订单尾号", fontsize=15)
plt.ylabel("饮料杯数", fontsize=15)
plt.title("订单尾号直方图", fontsize=18)
plt.show()
